package com.qst.mapreduce.wordcount.diliuzhang.sort;


import com.qst.mapreduce.wordcount.diliuzhang.dierjie.App;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortAppMapper extends Mapper<LongWritable, Text, SortApp, Text> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text,  SortApp, Text>.Context context) throws IOException, InterruptedException {
        String line=value.toString();
        // /t 制表符 分割
        String[] words=line.split("\t");
        SortApp app=new SortApp();
        //Text outkey=new Text(words[2]);
        app.setCount(Integer.parseInt(words[1]));
        app.setTime(Integer.parseInt(words[2]));
        app.setConsume(Integer.parseInt(words[3]));

        context.write(app,new Text(words[0]));



    }
}